import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'

Vue.use(VueRouter)

const routes = [{
		path: '/',
		name: 'Home',
		component: Home,
	},
	{
		path: '/solution/:id',
		name: 'solution',
		meta: {
			title: '解决方案'
		},
		component: () => import("../views/solution")
	},
	{
		path: '/solutionDetail/:id',
		name: 'solutionDetail',
		meta: {
			title: '解决方案'
		},
		component: () => import("../views/solutionDetail")
	},
	{
		path: '/news/:id',
		name: 'news',
		meta: {
			title: '新闻中心'
		},
		component: () => import("../views/news")
	},
	{
		path: '/newsDetail/:id',
		name: 'newsDetail',
		meta: {
			title: '新闻详情'
		},
		component: () => import("../views/newsDetail")
	},
	{
		path: '/profile',
		name: 'profile',
		meta: {
			title: '公司简介'
		},
		component: () => import("../views/profile")
	},
	{
		path: '/partner/:id',
		name: 'partner',
		meta: {
			title: '合作伙伴'
		},
		component: () => import("../views/partner")
	},
	{
		path: '/case/:id',
		name: 'case',
		meta: {
			title: '案例展示'
		},
		component: () => import("../views/case")
	},
	{
		path: '/listInfo/:id',
		name: 'listInfo',
		meta: {
			title: '文章详情'
		},
		component: () => import("../views/listInfo")
	},
]

const router = new VueRouter({
	routes,
	 scrollBehavior(to, from, savedPosition) {
	    if (to.hash) {
	      return { selector: to.hash }; // 滚动到锚点
	    } else {
	      return { x: 0, y: 0 }; // 滚动到页面顶部，或其他默认位置
	    }
	  }
})
// 解决ElementUI导航栏中重复点菜单报错问题
const originalPush = VueRouter.prototype.push
VueRouter.prototype.push = function push(location) {
	return originalPush.call(this, location).catch(err => err)
}


export default router